package com.example.programexpert

import android.annotation.SuppressLint
import android.os.Bundle
import android.widget.Button
import android.widget.LinearLayout
import android.widget.Spinner
import android.widget.TextView
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.colorspace.Rgb
import androidx.compose.ui.tooling.preview.Preview
import com.example.programexpert.ui.theme.ProgramExpertTheme

class MainActivity : ComponentActivity() {

    val expert = ProgramExpert()

    @SuppressLint("MissingInflatedId")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.mainlayout)

        val spinner = findViewById<Spinner>(R.id.spinner)
        val button = findViewById<Button>(R.id.button)
        val textView = findViewById<TextView>(R.id.textView)

//        button.setOnClickListener {
//            val selectedFeature = spinner.selectedItem.toString()
//            textView.text = selectedFeature
//        }

        button.setOnClickListener {
            textView.text = expert.getLanguage(spinner.selectedItem.toString())
        }


        val dynamicTexts: LinearLayout = findViewById(R.id.dynamic_texts)
        val buttonAddText: Button = findViewById(R.id.button2)

        buttonAddText.setOnClickListener {
            val count = dynamicTexts.childCount + 1
            val dynamicText = TextView(this).apply {
                text = "This is a new TextView: $count\n"
                textSize = 16f
                setBackgroundColor(android.graphics.Color.rgb(150,255,255))
                setPadding(16,12,16,12)
            }
            dynamicTexts.addView(dynamicText)
        }

    }
}
